Short circuiting statement evaluation -- is this guaranteed? [C#]

Posted by larryq on Stack Overflow See other posts from Stack Overflow or by larryq
Published on 2010-04-22T15:27:03Z Indexed on 2010/04/22 15:33 UTC
Read the original article Hit count: 388

Filed under:
|
|
|

Hi everyone,

Quick question here about short-circuiting statements in C#. With an if statement like this:

if (MyObject.MyArray.Count == 0 || MyObject.MyArray[0].SomeValue == 0)
{

//....
}

Is it guaranteed that evaluation will stop after the "MyArray.Count" portion, provided that portion is true? Otherwise I'll get a null exception in the second part.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about c#